<%= form_for @changeset, @action, [multipart: true, class: "ui form"], fn f -> %>
  <div class="field required <%= AdminHelpers.error_class(f, :author_id) %>">
    <%= label(f, :author_id, "Author") %>
    <div class="ui fluid remote author search selection dropdown">
      <%= hidden_input(f, :author_id) %>
      <i class="dropdown icon"></i>
      <%= if AdminHelpers.is_persisted(f.data) do %>
        <div class="selected text"><%= f.data.author.name %></div>
      <% else %>
        <div class="default text">Select Author</div>
      <% end %>
    </div>
    <%= AdminHelpers.error_message(f, :author_id) %>
  </div>

  <div class="field <%= AdminHelpers.error_class(f, :content) %>">
    <%= label(f, :content) %>
    <%= textarea(f, :content, placeholder: "Markdown enabled.", rows: 1)%>
    <%= AdminHelpers.error_message(f, :content) %>
  </div>

  <%= unless f.data.approved do %>
    <div class="field <%= AdminHelpers.error_class(f, :approved) %>">
      <%= label(f, :approved, "Approved") %>

      <div class="ui fluid selection dropdown">
        <%= hidden_input(f, :approved, value: "false") %>
        <i class="dropdown icon"></i>
        <div class="text">False</div>

        <div class="menu">
          <div class="item" data-value="true">True</div>
          <div class="item selected" data-value="false">False</div>
        </div>
      </div>
    </div>
  <% end %>

  <div class="ui hidden divider"></div>
  <div class="ui equal width stackable grid">
  <%= if !AdminHelpers.is_persisted(f.data) do %>
    <div class="column"><%= AdminHelpers.submit_button(:primary, "Create") %></div>
    <div class="column"><%= AdminHelpers.submit_button(:secondary, "Create and Close", AdminHelpers.next_param(@conn)) %></div>
  <% else %>
    <div class="column"><%= AdminHelpers.submit_button(:primary, "Save", SharedHelpers.current_path(@conn)) %></div>
    <div class="column"><%= AdminHelpers.submit_button(:secondary, "Save and Close", AdminHelpers.next_param(@conn)) %></div>
  <% end %>
    <div class="column"></div>
  </div>
<% end %>
